package alertmanager

import (
	

	
)

// Option represents an option that can be used to configure an
// alert manager.
type Option func(manager *Manager)

// Manager represents an alert manager.
type Manager struct {
	builder *sdk.AlertManager
}

// New creates a new alert manager.
func ( ...Option) *Manager {
	 := &Manager{
		builder: &sdk.AlertManager{},
	}

	for ,  := range  {
		()
	}

	return 
}

// ContactPoints defines the contact points that can receive alerts.
func ( ...Contact) Option {
	return func( *Manager) {
		 := &.builder.Config
		.Receivers = nil

		for ,  := range  {
			.Receivers = append(.Receivers, *.Builder)

			// we must have a default contact point, so we use the first contact point
			// if none is already set.
			if  == 0 && .Route.Receiver == "" {
				.Route.Receiver = .Builder.Name
			}
		}
	}
}

// DefaultContactPoint sets the default contact point to be used when no
// specific routing policy applies.
func ( string) Option {
	return func( *Manager) {
		.builder.Config.Route.Receiver = 
	}
}

// DefaultGroupBys sets the default labels that alerts should be grouped by.
func ( ...string) Option {
	return func( *Manager) {
		.builder.Config.Route.GroupBy = 
	}
}

// Templates defines templates that can be used when sending messages to
// contact points.
// See https://prometheus.io/blog/2016/03/03/custom-alertmanager-templates/
func ( map[string]string) Option {
	return func( *Manager) {
		.builder.TemplateFiles = 
	}
}

// Routing configures the routing policies to apply on alerts.
func ( ...RoutingPolicy) Option {
	return func( *Manager) {
		 := &.builder.Config
		.Route.Routes = nil

		for ,  := range  {
			.Route.Routes = append(.Route.Routes, *.builder)
		}
	}
}

// MarshalJSON implements the encoding/json.Marshaler interface.
func ( *Manager) () ([]byte, error) {
	return json.Marshal(.builder)
}

// MarshalIndentJSON renders the manager as indented JSON.
func ( *Manager) () ([]byte, error) {
	return json.MarshalIndent(.builder, "", "  ")
}